program string_t
  implicit none
  character(len=30) :: str
  str = 'hello'
  call length(str)
end program string_t

subroutine length(str)
  implicit none
  character(len=*), intent(in) :: str
  write(*,*) len(str)
  write(*,*) str
end subroutine length
